package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.po.Orders;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState,deliveried,deliveryManId) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0,0,0)")
	@Options(useGeneratedKeys = true, keyProperty = "orderId", keyColumn = "orderId")
	public int saveOrders(Orders orders);

	@Select("select * from orders where orderId=#{orderId}")
	public Orders getOrdersById(Integer orderId);

	@Select("select * from orders where userId=#{userId} order by userId")
	public List<Orders> listOrdersByUserId(String userId);

	//update 可修改收货地址和订单支付状态，多出两个按钮
	@Update("update orders set orderState=#{orderState} where orderId=#{orderId}")
	public int updateOrder(Orders orders);
	
	//delete 增加一个按钮
	@Delete("delete from orders where orderId=#{orderId}")
	public int removeOrders(Integer orderId);
}
